/**
 * fixed test functions for card unit tests
 * Team 15, 3/12/14
 *
 */

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "rngs.h"
#include <math.h>
#include "fixedCardUnitTests.h"
#include "cardUnitTestHelpers.h"

/**
 * fixed test function for adventurer card
 * tests council room card using initializeGame() to create new game.
 */
int fixedTestAdventurer(int unitOrInteg){
    int i; //loop counter
    int r; //initialization variable
    int a; //testing variable
    int bonus = 0; //placeholder for bonus
    int partialPass = 1; //for compound tests
    int failcount = 0; //track tests passed
    int passcount = 0; //track tests failed
    int check; //holds result returned from test function
    int seed = 1000;
    int numPlayer = 4;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    
    /*
     * test that playing council_room makes player draw 4 and discard 1 for
     * a net gain of 3, and that opposing player draws 1 card.
     * 
     */
    printf("\nTesting adventurer:\n\n");

    for (i = 0; i < numPlayer; i++){

        printf("Testing adventurer card played by player %d:\n", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
        
        //check for empty hand
        if (G.handCount[i] == 0){
            G.handCount[i] = 1;
        }

        G.hand[i][0] = adventurer; //put adventurer @ position 1        
        G.whoseTurn = i; //set turn to current player

        //store handcount for comparison
        a = G.handCount[i];        

        if (unitOrInteg == 1){
            check = cardEffect(adventurer, -1, -1, -1, &G, 0, &bonus);
            printf("cardEffect() returned %d after playing adventurer", check);
            printf(", Expected: 0\n");
        }
        else if (unitOrInteg == 2){
            check = playCard(0, -1, -1, -1, &G);
            printf("playCard() returned %d after playing adventurer", check);
            printf(", Expected: 0\n");
        }

        printf("playing adventurer set player %d's handcount to %d, ",
        i, G.handCount[i]);
        printf("Expected: %d\n", a + 1);

        if(G.handCount[i] != a + 1){
            partialPass = 0;
        }        
        if(check != 0){
            partialPass = 0;
        }
        if (partialPass == 1) {
            printf("TEST PASSED\n\n");
            passcount++;
        }
        else{
            printf("TEST FAILED\n\n");
            failcount++;
        }
    }

    if (failcount == 0){
        printf("All fixed adventurer tests passed!\n\n");
    }
    else{
        printf("%d fixed adventurer card tests failed. %d tests passed.\n", failcount, passcount);
        printf("Review log above for details.\n\n");
    }
    return 0;
}


/**
 * fixed test function for adventurer card
 * tests council room card using initializeGame() to create new game.
 */
int fixedTestCouncilRoom(int unitOrInteg){
    int i; //loop counter
    int r; //initialization variable
    int a; //testing variable
    int b; //testing variable
    int c; //testing variable
    int bonus = 0; //placeholder for bonus
    int oppositePlayer = 0; //opposite player
    int partialPass = 1; //for compound tests
    int failcount = 0; //track tests passed
    int passcount = 0; //track tests failed
    int check; //holds result returned from test function
    int seed = 1000;
    int numPlayer = 4;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    
    /*
     * test that playing council_room makes player draw 4 and discard 1 for
     * a net gain of 3, and that opposing player draws 1 card.
     * 
     */
    printf("\nTesting council_room:\n\n");

    for (i = 0; i < numPlayer; i++){

        printf("Testing council_room card played by player %d:\n", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
        
        //check for empty hand
        if (G.handCount[i] == 0){
            G.handCount[i] = 1;
        }

        G.hand[i][0] = council_room; //put council_room @ position 1        
        G.whoseTurn = i; //set turn to current player

        //switch for opposite players
        if (i == 0){
            oppositePlayer = 1;
        }
        else {
            oppositePlayer = 0;
        }

        a = G.handCount[i];
        b = G.handCount[oppositePlayer];
        c = G.numBuys;
        
        if (unitOrInteg == 1){
            check = cardEffect(council_room, -1, -1, -1, &G, 0, &bonus);
            printf("cardEffect() returned %d after playing council_room", check);
            printf(", Expected: 0\n");

            printf("cardEffect set numBuys to %d, ", G.numBuys);
            printf("Expected: %d", c + 1);
        }

        else if (unitOrInteg == 2){
            check = playCard(0, -1, -1, -1, &G);            
            printf("playCard() returned %d after playing council_room", check);
            printf(", Expected: 0\n");

            printf("playCard set numBuys to %d, ", G.numBuys);
            printf("Expected: %d", c + 1);
        }

            printf("playing council_room set player %d's handcount to %d, ",
            i, G.handCount[i]);
            printf("Expected: %d\n", a + 3);


            printf("playing council_room set player %d's handcount to %d, ",
            oppositePlayer, G.handCount[oppositePlayer]);
            printf("Expected: %d\n", b + 1);


        if(G.handCount[oppositePlayer] != b + 1){
            partialPass = 0;
        }
        if(G.handCount[i] != a + 3){
            partialPass = 0;
        }
        if(G.numBuys != c + 1){
            partialPass = 0;
        }
        if(check != 0){
            partialPass = 0;
        }
        if (partialPass == 1) {
            printf("TEST PASSED\n\n");
            passcount++;
        }
        else{
            printf("TEST FAILED\n\n");
            failcount++;
        }
    }

    if (failcount == 0){
        printf("All fixed council room tests passed!\n\n");
    }
    else{
        printf("%d fixed council room card tests failed. %d tests passed.\n", failcount, passcount);
        printf("Review log above for details.\n\n");
    }
    return 0;
}


/**
 *  Fixed tests for village card
 *  uses initializeGame() to create gamestate
 *
 */
int fixedTestVillage(int unitOrInteg){

    int i; //loop counter
    int r; //initialization variable
    int a; //testing variable for empty pile
    int b; //testing variable for empty pile
    int bonus = 0; //placeholder for bonus
    int partialPass = 1; //for compound tests
    int failcount = 0; //track tests passed
    int passcount = 0; //track tests failed
    int check; //holds result returned from test function
    int seed = 1000;
    int numPlayer = 4;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    
    /*
     * test that playing council_room makes player draw 4 and discard 1 for
     * a net gain of 3, and that opposing player draws 1 card.
     * 
     */

    printf("\nTesting village card:\n\n");

    for (i = 0; i < numPlayer; i++){

        printf("Testing village card played by player %d:\n", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
        
        //check for empty hand
        if (G.handCount[i] == 0){
            G.handCount[i] = 1;
        }

        G.hand[i][0] = village; //put council_room @ position 1
        G.whoseTurn = i; //set turn to current player


        a = G.handCount[i];
        b = G.numActions;        

        //unit test
        if (unitOrInteg == 1){
            check = cardEffect(village, -1, -1, -1, &G, 0, &bonus);
            printf("cardEffect() returned %d after playing village", check);
            printf(", Expected: 0\n");
        }

        //integration test
        else if (unitOrInteg == 2){
            check = playCard(0, -1, -1, -1, &G);
            printf("playCard() returned %d after playing village", check);
            printf(", Expected: 0\n");
        }

        printf("playing village set player %d's handcount to %d, ",
        i, G.handCount[i]);
        printf("Expected: %d\n", a);

        //unit test
        if (unitOrInteg == 1){
            printf("playing village set numActions to %d, ", G.numActions);
            printf("Expected: %d\n", b + 2);
            
            if(G.numActions != b + 2){
            partialPass = 0;
            }   

        }

        //integration test
        if (unitOrInteg == 2){
            printf("playing village set numActions to %d, ", G.numActions);
            printf("Expected: %d\n", b + 1);
            
            if(G.numActions != b + 1){
            partialPass = 0;
            }   

        }                


        if(G.handCount[i] != a){
            partialPass = 0;
        }          
     
        if(check != 0){
            partialPass = 0;
        }
        if (partialPass == 1) {
            printf("TEST PASSED\n\n");
            passcount++;
        }
        else{
            printf("TEST FAILED\n\n");
            failcount++;
        }
    }

    if (failcount == 0){
        printf("All fixed village tests passed!\n\n");
    }
    else{
        printf("%d fixed village tests failed. %d tests passed.\n", failcount, passcount);
        printf("Review log above for details.\n\n");
    }
    return 0;
}



int fixedTestGreatHall(int unitOrInteg){
    int i; //loop counter
    int r; //initialization variable
    int a; //testing variable for empty pile
    int b; //testing variable for empty pile
    int bonus = 0; //placeholder for bonus
    int partialPass = 1; //for compound tests
    int failcount = 0; //track tests passed
    int passcount = 0; //track tests failed
    int check; //holds result returned from test function
    int seed = 1000;
    int numPlayer = 4;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    
    /*
     * test that playing council_room makes player draw 4 and discard 1 for
     * a net gain of 3, and that opposing player draws 1 card.
     * 
     */

    printf("\nTesting great_hall card:\n\n");

    for (i = 0; i < numPlayer; i++){

        printf("Testing great_hall card played by player %d:\n", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
        
        //check for empty hand
        if (G.handCount[i] == 0){
            G.handCount[i] = 1;
        }

        G.hand[i][0] = great_hall; //put great_hall @ position 1
        G.whoseTurn = i; //set turn to current player


        a = G.handCount[i];
        b = G.numActions;        

        if (unitOrInteg == 1){
            check = cardEffect(great_hall, -1, -1, -1, &G, 0, &bonus);
            printf("cardEffect() returned %d after playing great_hall", check);
            printf(", Expected: 0\n");
        }
        else{
            check = playCard(0, -1, -1, -1, &G);
            printf("playCard() returned %d after playing great_hall", check);
            printf(", Expected: 0\n");
        }

        printf("playing great_hall set player %d's handcount to %d, ",
        i, G.handCount[i]);
        printf("Expected: %d\n", a);

        if (unitOrInteg == 1){

        printf("playing great_hall set numActions to %d, ", G.numActions);
        printf("Expected: %d\n", b + 1);  

            if(G.numActions != b + 1){
                partialPass = 0;
            }  

        }

        else if (unitOrInteg == 2){

        printf("playing great_hall set numActions to %d, ", G.numActions);
        printf("Expected: %d\n", b);  

            if(G.numActions != b){
                partialPass = 0;
            }  

        }

        if(G.handCount[i] != a){
            partialPass = 0;
        }          
      
        if(check != 0){
            partialPass = 0;
        }
        if (partialPass == 1) {
            printf("TEST PASSED\n\n");
            passcount++;
        }
        else{
            printf("TEST FAILED\n\n");
            failcount++;
        }
    }

    if (failcount == 0){
        printf("All fixed great hall tests passed!\n\n");
    }
    else{
        printf("%d fixed great hall tests failed. %d tests passed.\n", failcount, passcount);
        printf("Review log above for details.\n\n");
    }
    return 0;
}


int fixedTestOutpost(int unitOrInteg){
    int i; //loop counter
    int r; //initialization variable
    int a; //testing variable for empty pile
    int b; //testing variable for empty pile
    int bonus = 0; //placeholder for bonus
    int partialPass = 1; //for compound tests
    int failcount = 0; //track tests passed
    int passcount = 0; //track tests failed
    int check; //holds result returned from test function
    int seed = 1000;
    int numPlayer = 4;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    
    /*
     * test that playing council_room makes player draw 4 and discard 1 for
     * a net gain of 3, and that opposing player draws 1 card.
     * 
     */
    printf("\n\nTesting outpost card:\n\n");

    for (i = 0; i < numPlayer; i++){

        printf("Testing outpost card played by player %d:\n", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
        
        //check for empty hand
        if (G.handCount[i] == 0){
            G.handCount[i] = 1;
        }

        G.hand[i][0] = outpost; //put council_room @ position 1
        G.whoseTurn = i; //set turn to current player


        a = G.handCount[i];
        b = G.outpostPlayed;        

        if (unitOrInteg == 1){
            check = cardEffect(outpost, -1, -1, -1, &G, 0, &bonus);
            printf("cardEffect() returned %d after playing outpost", check);
            printf(", Expected: 0\n");
        }
        else if (unitOrInteg == 2){
            check = playCard(0, -1, -1, -1, &G);
            printf("playCard() returned %d after playing outpost", check);
            printf(", Expected: 0\n");
        }
        printf("playing outpost set player %d's handcount to %d, ",
        i, G.handCount[i]);
        printf("Expected: %d\n", a - 1);

        printf("playing outpost set outpostPlayed to %d, ", G.outpostPlayed);
        printf("Expected: %d\n", b + 1);        


        if(G.handCount[i] != a - 1){
            partialPass = 0;
        }          
        if(G.outpostPlayed != b + 1){
            partialPass = 0;
        }        
        if(check != 0){
            partialPass = 0;
        }
        if (partialPass == 1) {
            printf("TEST PASSED\n\n");
            passcount++;
        }
        else{
            printf("TEST FAILED\n\n");
            failcount++;
        }
    }

    if (failcount == 0){
        printf("All fixed outpost tests passed!\n\n");
    }
    else{
        printf("%d fixed outpost tests failed. %d tests passed.\n", failcount, passcount);
        printf("Review log above for details.\n\n");
    }
    return 0;
}

int fixedTestMine(int unitOrInteg){
    int i; //loop counter
    int r; //initialization variable
    int bonus = 0; //placeholder for bonus
    int partialPass = 1; //for compound tests
    int failcount = 0; //track tests passed
    int passcount = 0; //track tests failed
    int check; //holds result returned from test function
    int seed = 1000;
    int numPlayer = 4;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    
    /*
     * test that playing council_room makes player draw 4 and discard 1 for
     * a net gain of 3, and that opposing player draws 1 card.
     * 
     */

    printf("\nTesting mine card:\n\n");


    //test invalid input < copper
    for (i = 0; i < numPlayer; i++){

        printf("Testing mine card played by player %d\nwith invalid choice 1 (< copper)", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
        
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 2){
            G.handCount[i] = 2;
        }

        G.hand[i][0] = mine; //put mine @ position 1
        G.hand[i][1] = curse;
        G.whoseTurn = i; //set turn to current player

        if (unitOrInteg == 1){
            check = cardEffect(mine, 1, -1, -1, &G, 0, &bonus);
        }
        else if(unitOrInteg == 2){
            check = playCard(0, 1, -1, -1, &G);
        }

        if (check != -1){
            printf("\nExpected return value = -1, got: %d\n", check);
            printf("\nTEST FAILED\n\n");
            failcount++;
        }
        else{
            printf("\nExpected return value = -1, got: %d\n", check);
            printf("TEST PASSED\n\n");
            passcount++;
        }
    }


    //test invalid input > gold
    printf("---------------\n");
        for (i = 0; i < numPlayer; i++){

        printf("Testing mine card played by player %d\nwith invalid choice 1 (> gold)", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
        
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 2){
            G.handCount[i] = 2;
        }

        G.hand[i][0] = mine; //put mine @ position 1
        G.hand[i][1] = treasure_map;
        G.whoseTurn = i; //set turn to current player

        
        if (unitOrInteg == 1){
            check = cardEffect(mine, 1, -1, -1, &G, 0, &bonus);
        }
        else if(unitOrInteg == 2){
            check = playCard(0, 1, -1, -1, &G);
        }
        

        if (check != -1){
            printf("\nExpected return value = -1, got: %d\n", check);
            printf("\nTEST FAILED\n\n");
            failcount++;
        }
        else{
            printf("\nExpected return value = -1, got: %d\n", check);
            printf("TEST PASSED\n\n");
            passcount++;
        }
    }

    //test invalid input > treasure_map
    printf("---------------\n");
    for (i = 0; i < numPlayer; i++){

        printf("Testing mine card played by player %d\nwith invalid choice 2 (> treasure_map)", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
        
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 2){
            G.handCount[i] = 2;
        }

        G.hand[i][0] = mine; //put mine @ position 1
        G.hand[i][1] = copper;
        G.whoseTurn = i; //set turn to current player

        

        if (unitOrInteg == 1){
            check = cardEffect(mine, 1, (treasure_map + 1), -1, &G, 0, &bonus);
        }
        else if(unitOrInteg == 2){
            check = playCard(0, 1, (treasure_map + 1), -1, &G);
        }
        

        if (check != -1){
            printf("\nExpected return value = -1, got: %d\n", check);
            printf("TEST FAILED\n\n");
            failcount++;
        }
        else{
            printf("\nExpected return value = -1, got: %d\n", check);
            printf("TEST PASSED\n\n");
            passcount++;
        }
    }
    //test invalid input < curse
    printf("---------------\n");
    for (i = 0; i < numPlayer; i++){

        printf("Testing mine card played by player %d\nwith invalid choice 2 (< curse)", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
        
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 2){
            G.handCount[i] = 2;
        }

        G.hand[i][0] = mine; //put mine @ position 1
        G.hand[i][1] = copper;
        G.whoseTurn = i; //set turn to current player

        if (unitOrInteg == 1){
            check = cardEffect(mine, 1, (curse - 1), -1, &G, 0, &bonus);
        }
        else if(unitOrInteg == 2){
            check = playCard(0, 1, (curse - 1), -1, &G);
        }
        
        if (check != -1){
            printf("\nExpected return value = -1, got: %d\n", check);
            printf("TEST FAILED\n\n");
            failcount++;
        }
        else{
            printf("\nExpected return value = -1, got: %d\n", check);
            printf("TEST PASSED\n\n");
            passcount++;
        }
    }
    //test invalid input card too pricey
        printf("---------------\n");
        for (i = 0; i < numPlayer; i++){

        printf("Testing mine card played by player %d\nwith invalid choice 2 (too expensive)", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
        
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 2){
            G.handCount[i] = 2;
        }

        G.hand[i][0] = mine; //put mine @ position 1
        G.hand[i][1] = copper;
        G.whoseTurn = i; //set turn to current player
        
        if (unitOrInteg == 1){
            check = cardEffect(mine, 1, council_room, -1, &G, 0, &bonus);
        }
        else if(unitOrInteg == 2){
            check = playCard(0, 1, council_room, -1, &G);
        }
        

        if (check != -1){
            printf("\nExpected return value = -1, got: %d\n", check);
            printf("TEST FAILED\n\n");
            failcount++;
        }
        else{
            printf("\nExpected return value = -1, got: %d\n", check);
            printf("TEST PASSED\n\n");
            passcount++;
        }
    }
    //test valid input

    printf("---------------\n");
    for (i = 0; i < numPlayer; i++){
        partialPass = 1;

        printf("Testing mine card played by player %d\nwith valid input: swapping silver for adventurer", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
        
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 2){
            G.handCount[i] = 2;
        }

        G.hand[i][0] = mine; //put mine @ position 1
        G.hand[i][1] = silver;
        G.whoseTurn = i; //set turn to current player

        int handCountMonitor = G.handCount[i];

        if (unitOrInteg == 1){
            check = cardEffect(mine, 1, adventurer, -1, &G, 0, &bonus);
        }
        else if(unitOrInteg == 2){
            check = playCard(0, 1, adventurer, -1, &G);
        }       

        
        printf("\nExpected return value = 0, got: %d\n", check);
        if (check != 0){
            partialPass = 0;
        }

        //check that adventurer was gained
        int adventurerCheck = 0;
        int f;
        for (f = 0; f < G.handCount[i]; f++){
            if (G.hand[i][f] == adventurer){
                adventurerCheck = 1;
                break;
            }
        }   
        printf("\nExpected to gain adventurer card.  Hand contains adventurer card? 1 = yes, 0 = no: %d", adventurerCheck);
        
        if (adventurerCheck == 0){
            partialPass = 0;

        }
        //check for net gain of -1 due to discard and swap
        printf("\nExpected net gain of -1.  Actual net gain: %d", G.handCount[i] - handCountMonitor);
        if (G.handCount[i] - handCountMonitor != -1){
            partialPass = 0;
        }
        if (partialPass == 1){
            printf("\nTEST PASSED\n\n");
        }
        else{
            printf("\nTEST FAILED\n\n");
            failcount++;
        }
    }
    if (failcount == 0){
        printf("ALL FIXED MINE TESTS PASSED\n\n");
    }
    else {
        printf("%d TESTS PASSED", passcount);
        printf("\n%d TESTS FAILED\n\n", failcount);
    }
    return 0;
}

//easy random implementation possible, too
int fixedTestSmithy(int unitOrInteg){
    int i; //loop counter
    int r; //initialization variable
    int bonus = 0; //placeholder for bonus
    int failcount = 0; //track tests passed
    int passcount = 0; //track tests failed
    int check; //holds result returned from test function
    int seed = 1000;
    int numPlayer = 4;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    
    /*
     * test that playing council_room makes player draw 4 and discard 1 for
     * a net gain of 3, and that opposing player draws 1 card.
     * 
     */

    printf("\nTesting smithy card:\n\n");


    //test invalid input < copper
    for (i = 0; i < numPlayer; i++){
        printf("Testing smithy card played by player %d ", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
        
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 1){
            G.handCount[i] = 1;
        }

        G.hand[i][0] = smithy; //put mine @ position 1        
        G.whoseTurn = i; //set turn to current player

        int handCountMonitor = G.handCount[i];

        if (unitOrInteg == 1){
            check = cardEffect(smithy, 1, -1, -1, &G, 0, &bonus);
        }
        else if(unitOrInteg == 2){
            check = playCard(0, 1, -1, -1, &G);
        }

        int diff = (G.handCount[i] - handCountMonitor);
        printf("Expected player to gain net 2 cards.\n Player gained %d cards", diff);
        if (diff != 2){
            printf("\nTEST FAILED\n\n");
        }
        else {
            printf("\nTEST PASSED\n\n");
        }
    }
        if (failcount == 0){
           printf("ALL TESTS PASSED\n");
        }
        else {
            printf("%d TESTS PASSED\n", passcount);
            printf("\n%d TESTS FAILED\n", failcount);
        }
    return 0;

}



int fixedTestFeast(int unitOrInteg){
    int i; //loop counter
    int r; //initialization variable
    int bonus = 0; //placeholder for bonus
    int partialPass = 1; //for compound tests
    int failcount = 0; //track tests passed
    int passcount = 0; //track tests failed
    int check; //holds result returned from test function
    int seed = 1000;
    int numPlayer = 4;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    
    /*
     * test that playing council_room makes player draw 4 and discard 1 for
     * a net gain of 3, and that opposing player draws 1 card.
     * 
     */

    printf("\nTesting feast card:\n\n");

    for (i = 0; i < numPlayer; i++){
    partialPass = 1;
    printf("Testing feast card played by player %d with invalid input"
     "\n(attempt to buy card costing more than 5)\n", i);
    memset(&G, 23, sizeof(struct gameState));   // clear the game state
    r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
    
    //check for small hand (min 2 needed)
    if (G.handCount[i] < 1){
        G.handCount[i] = 1;
    }

    //
    G.hand[i][0] = feast; //put mine @ position 1        
    G.whoseTurn = i; //set turn to current player



    //control state
    struct gameState pre;
    memcpy (pre.hand[i], G.hand[i], sizeof(int) * MAX_HAND);

    if (unitOrInteg == 1){
        check = cardEffect(feast, adventurer, -1, -1, &G, 0, &bonus);
    }
    else if (unitOrInteg == 2){
        check = playCard(0, adventurer, -1, -1, &G);
    }


    //check for no change in hand
    printf("Expected no change to hand.  \nObserved:");
    if(memcmp(pre.hand[i], G.hand[i], sizeof(int) * MAX_HAND) == 0){
        printf("no change");
    }
    else {
        printf("change");
        partialPass = 0;
    }



    //check for 0 return
    printf("\nExpeted return value of -1.  \nObserved: %d", check);
    if (check != -1){
        partialPass = 0;
    }



    if (partialPass == 0){
        failcount++;
        printf("\nTEST FAILED\n\n");
    }
    else {
        passcount++;
        printf("\nTEST PASSED\n\n");
    }

}
    //invalid input
    for (i = 0; i < numPlayer; i++){
        partialPass = 1;
        printf("Testing feast card played by player %d with invalid input"
         "\n(attempt to buy card with empty supply pile)\n", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
    
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 1){
            G.handCount[i] = 1;
        }

        //
        G.hand[i][0] = feast; //put mine @ position 1        
        G.whoseTurn = i; //set turn to current player
        G.supplyCount[mine] = 0;



        //control state
        struct gameState pre;
        memcpy (pre.hand[i], G.hand[i], sizeof(int) * MAX_HAND);

        if (unitOrInteg == 1){
            check = cardEffect(feast, mine, -1, -1, &G, 0, &bonus);
        }
        else if (unitOrInteg == 2){
            check = playCard(0, mine, -1, -1, &G);
        }


        //check for no change hand
        printf("Expected no change to gamestate.  \nObserved:");
        if(memcmp(pre.hand[i], G.hand[i], sizeof(int) * MAX_HAND) == 0){
            printf("no change");
        }
        else {
            printf("change");
            partialPass = 0;
        }



        //check for 0 return
        printf("\nExpeted return value of -1.  \nObserved: %d", check);
        if (check != -1){
            partialPass = 0;
        }



        if (partialPass == 0){
            failcount++;
            printf("\nTEST FAILED\n\n");
        }
        else {
            passcount++;
            printf("\nTEST PASSED\n\n");
        }
    
    }

    //testing valid input

        for (i = 0; i < numPlayer; i++){
        partialPass = 1;
        printf("Testing feast card played by player %d with valid input"
         "\n(attempt to buy card with empty supply pile)\n", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
    
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 1){
            G.handCount[i] = 1;
        }

        //
        G.hand[i][0] = feast; //put mine @ position 1        
        G.whoseTurn = i; //set turn to current player
        

        int checkDiscardCount = G.discardCount[i];
        int checkHandCount = G.handCount[i];

        //control state
        struct gameState pre;
        memcpy (pre.hand[i], G.hand[i], sizeof(int) * MAX_HAND);

        if (unitOrInteg == 1){
            check = cardEffect(feast, mine, -1, -1, &G, 0, &bonus);
        }
        else if (unitOrInteg == 2){
            check = playCard(0, mine, -1, -1, &G);
        }

        //check that card added to discard pile
        //NEED FIX
        printf("Expected mine card to be added to discard pile\n");
        //printf("preDiscardCount: %d, postDiscardCount: %d", checkDiscardCount, G.discardCount[i]);
        if (G.discardCount[i] == checkDiscardCount + 1){
            if (G.discard[i][G.discardCount[i] - 1] == mine){
                printf("Mine card was added to discard pile\n");
             }
        }
        else{
            printf("Mine Card was not added to discard pile\n");
            partialPass = 0;
        }

        //check for net gain of -1 in hand
        printf("Expected net gain of -1");
        if (G.handCount[i] == checkHandCount - 1){
            printf("\nObserved net gain of -1");
        }
        else{
            printf("\nObserved net gain of %d", G.handCount[i] - checkHandCount);
            partialPass = 0;
        }   



        //check for 0 return
        printf("\nExpeted return value of 0.  \nObserved: %d", check);
        if (check != 0){
            partialPass = 0;
        }



        if (partialPass == 0){
            failcount++;
            printf("\nTEST FAILED\n\n");
        }
        else {
            passcount++;
            printf("\nTEST PASSED\n\n");
        }


    
    }
    if (failcount == 0){
        printf("All fixed feast tests passed\n");
    }
    else {
        printf("%d fixed feast tests passed\n%d fixed feast tests failed\n",
            passcount, failcount);
    }

    return 0;
}

int fixedTestRemodel(int unitOrInteg){    
    int i; //loop counter
    int r; //initialization variable
    int bonus = 0; //placeholder for bonus
    int partialPass = 1; //for compound tests
    int failcount = 0; //track tests passed
    int passcount = 0; //track tests failed
    int check; //holds result returned from test function
    int seed = 1000;
    int numPlayer = 4;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    
    /*
     * test that playing council_room makes player draw 4 and discard 1 for
     * a net gain of 3, and that opposing player draws 1 card.
     * 
     */

    printf("\nTesting remodel card:\n\n");

    for (i = 0; i < numPlayer; i++){
        partialPass = 1;
        printf("Testing remodel card played by player %d with invalid input"
         "\n(attempt to buy card costing more than 2 + choice 1)\n", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
    
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 2){
            G.handCount[i] = 2;
        }

        //
        G.hand[i][0] = remodel; //put remodel @ position 1  
        G.hand[i][1] = curse; //put low value card @ position 1 for testing invalid cost differential     
        G.whoseTurn = i; //set turn to current player


        if (unitOrInteg == 1){
            check = cardEffect(remodel, 1, adventurer, -1, &G, 0, &bonus);
        }
        else if (unitOrInteg == 2){
            check = playCard(0, 1, adventurer, -1, &G);
        }

        printf("Expected return of -1.  Observed: %d.\n", check);
        if (check != -1){
            printf("TEST FAILED\n\n");
            failcount++;
        }
        else{
            printf("TEST PASSED\n\n");
            passcount++;
        }
    }

        for (i = 0; i < numPlayer; i++){
        partialPass = 1;
        printf("\n\nTesting remodel card played by player %d with valid input\n", i);
         
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
    
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 3){
            G.handCount[i] = 3;
        }

        //
        G.hand[i][0] = remodel; //put remodel @ position 1  
        G.hand[i][1] = village; //put medium value card for testing
        G.hand[i][2] = village; //include it twice to check discard
        G.whoseTurn = i; //set turn to current player

        if (unitOrInteg == 1){
            check = cardEffect(remodel, 1, baron, -1, &G, 0, &bonus);
        }
        else if (unitOrInteg == 2){
            check = playCard(0, 1, baron, -1, &G);
        }

        printf("\nExpected return of 0.  Observed: %d.", check);
        if (check != 0){
            partialPass = 0;
        }
        

        printf("\nExpected to gain baron card as top of discard pile");
        int card = G.discard[i][G.discardCount[i] - 1];
        if (card == baron){
            printf("\nObserved: baron card");
        }
        else {
            printf("\nObserved %s card", getCard(card));
            printf("%d", G.discardCount[i]);
            partialPass = 0;
        }

        printf("\nExpected top 2 cards of played card pile to be: village and remodel");
        printf("\nObserved: %s and %s", getCard(G.playedCards[G.playedCardCount - 1]), getCard(G.playedCards[G.playedCardCount - 2]));
        if (G.playedCards[G.playedCardCount - 1] != village || G.playedCards[G.playedCardCount - 2] != remodel){
            partialPass = 0;
        }

        if (partialPass == 0){
            printf("\nTEST FAILED\n\n");
            failcount++;
        }
        else {
            printf("\nTEST PASSED\n\n");
            passcount++;
        }
    }

    if (failcount == 0){
        printf("All fixed remodel tests passed\n");
    }
    else {
        printf("%d fixed remodel tests passed\n%d fixed feast tests failed\n",
            passcount, failcount);
    }

    return 0;
}

int fixedTestSteward(int unitOrInteg){
    int i; //loop counter
    int r; //initialization variable
    int bonus = 0; //placeholder for bonus
    int partialPass = 1; //for compound tests
    int failcount = 0; //track tests passed
    int passcount = 0; //track tests failed
    int check; //holds result returned from test function
    int seed = 1000;
    int numPlayer = 4;
    int k[10] = {adventurer, steward, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;


    printf("\nTesting steward card:\n\n");

    //test invalid input
    for (i = 0; i < numPlayer; i++){
        partialPass = 1;
        printf("Testing steward card played by player %d with invalid input"
         "\n(choice 1 value other than 1, 2, or 3)\n", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
    
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 3){
            G.handCount[i] = 3;
        }

        //
        G.hand[i][0] = steward; //put steward @ position 1  
        G.hand[i][1] = curse; //arbitrary card at position 2
        G.hand[i][2] = feast; //arbitrary card at position 3
        G.whoseTurn = i; //set turn to current player

        if (unitOrInteg == 1){
            check = cardEffect(steward, 4, -1, -1, &G, 0, &bonus);
            printf("Expected return of -1.  CardEffect() returned: %d", check);
        }
        else if (unitOrInteg == 2) {                        
            check = playCard(0, 4, -1, -1, &G);
            printf("Expected return of -1.  PlayCard() returned: %d", check);       
        }            

        if (check != -1){
            printf("\nTEST FAILED\n\n");
            failcount++;
        }
        else {
            printf("\nTEST PASSED\n\n");
            passcount++;
        }

    
    }

    printf("==============\n\n");

    //valid input test: draw 2 cards
    for (i = 0; i < numPlayer; i++){
        partialPass = 1;
        printf("Testing steward card played by player %d with valid input"
         "\n(flag to draw 2 cards)\n", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
    
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 3){
            G.handCount[i] = 3;
        }

        //
        G.hand[i][0] = steward; //put steward @ position 1  
        G.hand[i][1] = curse; //arbitrary card at position 2
        G.hand[i][2] = feast; //arbitrary card at position 3
        G.whoseTurn = i; //set turn to current player        
        int handCountMonitor = G.handCount[i];


        //UNIT TEST
        if (unitOrInteg == 1){

            check = cardEffect(steward, 1, -1, -1, &G, 0, &bonus);
            printf("Expected return of 0.  CardEffect() returned: %d", check);
        }
        //INTEGRATION TEST
        else if (unitOrInteg == 2) {            
            check = playCard(0, 1, -1, -1, &G);
            printf("Expected return of 0.  PlayCard() returned: %d", check);       
        }

        if (check != 0){
            partialPass = 0;
        }

        int handCountDiff = G.handCount[i] - handCountMonitor;
        printf("\nExpected handCount to increase by 1 (due to discard of steward)");
        printf("\nObserved gain of: %d.\n", handCountDiff);

        if (handCountDiff != 1){
            partialPass = 0;
        }

        int discarded = G.playedCards[G.playedCardCount - 1];        
        printf("Expected steward card to be on top of played card pile");
        printf("\nObserved %s card on top of played card pile", getCard(discarded));
        
        if (discarded != steward){
            partialPass = 0;
        }

        if (partialPass == 0){
            printf("\nTEST FAILED\n\n");
            failcount++;
        }
        else{
            printf("\nTEST PASSED\n\n");
            passcount++;
        }
    }

    printf("==============\n\n");

    //valid input test: pick up 2 coins
    for (i = 0; i < numPlayer; i++){
        partialPass = 1;
        printf("Testing steward card played by player %d with valid input"
         "\n(flag to gain 2 coins)\n", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
    
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 3){
            G.handCount[i] = 3;
        }
        int handCountMonitor = G.handCount[i];
        int coinCountMonitor = 0;

        //
        G.hand[i][0] = steward; //put steward @ position 1  
        G.hand[i][1] = curse; //arbitrary card at position 2
        G.hand[i][2] = feast; //arbitrary card at position 3
        G.whoseTurn = i; //set turn to current player

        //UNIT TESTS STARTER
        if (unitOrInteg == 1){
            coinCountMonitor = G.coins;
            check = cardEffect(steward, 2, -1, -1, &G, 0, &bonus);
            printf("Expected return of 0.  CardEffect() returned: %d", check);
        }
        //INTEGRATION TESTS STARTER
        else if (unitOrInteg == 2) {
            coinCountMonitor = 0;
            //-- GET CURRENT COIN VALUE BY SIMULATING UPDATECOINS
            int j;
            for (j = 0; j < G.handCount[i]; j++)
            {
                if (G.hand[i][j] == copper)
                {
                    coinCountMonitor += 1;
                }
                else if (G.hand[i][j] == silver)
                {
                   coinCountMonitor += 2;
                }
                else if (G.hand[i][j] == gold)
                {
                    coinCountMonitor += 3;
                }   
            }               
            check = playCard(0, 2, -1, -1, &G);
            printf("Expected return of 0.  PlayCard() returned: %d", check);       
        }

        if (check != 0){
            partialPass = 0;
        }

        int handCountDiff = G.handCount[i] - handCountMonitor;
        printf("\nExpected handCount to decrease by 1 (due to discard of steward)");
        printf("\nObserved gain of: %d.", handCountDiff);

        if (handCountDiff != -1){
            partialPass = 0;
        }

        int coinCountDiff = G.coins - coinCountMonitor;
        printf("\nExpected coin count to increase by 2");
        printf("\nObserved gain of: %d.\n", coinCountDiff);

        if (coinCountDiff != 2){
            partialPass = 0;
        }

        int discarded = G.playedCards[G.playedCardCount - 1];        
        printf("Expected steward card to be on top of played card pile");
        printf("\nObserved %s card on top of played card pile", getCard(discarded));
        
        if (discarded != steward){
            partialPass = 0;
        }

        if (partialPass == 0){
            printf("\nTEST FAILED\n\n");
            failcount++;
        }
        else{
            printf("\nTEST PASSED\n\n");
            passcount++;
        }
    }

    printf("==============\n\n");

    //valid input test: trash 2 cards
    for (i = 0; i < numPlayer; i++){
        partialPass = 1;
        printf("Testing steward card played by player %d with valid input"
         "\n(flag to trash 2 cards)\n", i);
        memset(&G, 23, sizeof(struct gameState));   // clear the game state
        r = initializeGame(numPlayer, k, seed, &G); // initialize a new game
    
        //check for small hand (min 2 needed)
        if (G.handCount[i] < 3){
            G.handCount[i] = 3;
        }
        int handCountMonitor = G.handCount[i];
        int playedCardsMonitor = G.playedCardCount;

        //
        G.hand[i][0] = steward; //put steward @ position 1  
        G.hand[i][1] = curse; //arbitrary card at position 2
        G.hand[i][2] = feast; //arbitrary card at position 3
        G.whoseTurn = i; //set turn to current player

        if (unitOrInteg == 1){
            check = cardEffect(steward, 3, 1, 2, &G, 0, &bonus);
            printf("Expected return of 0.  CardEffect() returned: %d", check);
        }
        else if (unitOrInteg == 2) {            
            check = playCard(0, 3, 1, 2, &G);
            printf("Expected return of 0.  PlayCard() returned: %d", check);       
        }

        if (check != 0){
            partialPass = 0;
        }

        int handCountDiff = G.handCount[i] - handCountMonitor;
        printf("\nExpected handCount to decrease by 3 (due to discard of steward)");
        printf("\nObserved gain of: %d.\n", handCountDiff);

        if (handCountDiff != -3){
            partialPass = 0;
        }

        int discarded = G.playedCards[G.playedCardCount - 1];        
        printf("Expected steward card to be on top of played card pile");
        printf("\nObserved %s card on top of played card pile", getCard(discarded));
        
        if (discarded != steward){
            partialPass = 0;
        }

        int playedCardsChange = G.playedCardCount - playedCardsMonitor;
        printf("Expected playedCards pile to increase by only 1\n"
            "due to discarded cards being trashed");
        printf("\nObserved increase of %d.", playedCardsChange);

        if (playedCardsChange != 1){
            partialPass = 0;
        }

        if (partialPass == 0){
            printf("\nTEST FAILED\n\n");
            failcount++;
        }
        else{
            printf("\nTEST PASSED\n\n");
            passcount++;
        }
    }

    if (failcount == 0){
        printf("ALL FIXED STEWARD TESTS PASSED\n\n");
    }
    else {
        printf("%d FIXED STEWARD TESTS PASSED\n", passcount);
        printf("%d FIXED STEWARD TESTS FAILED\n\n", failcount);
    }

    return 0;

}

